/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.telefonica.bmws.ws;
import java.sql.SQLException;

import javax.annotation.Resource;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.servlet.http.HttpServletRequest;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPMessageContext;

import org.apache.log4j.Logger;

import com.telefonica.bmws.dao.DesbloqueaAbonadoDAO;
import com.telefonica.bmws.parameter.DesbloqueaAbonadoParameter;
import com.telefonica.bmws.result.DesbloqueaAbonadoResult;
/**
 *
 * @author MARC-XARLIE
 */
@WebService(portName = "DesbloqueaAbonadoWsPort",serviceName="DesbloqueaAbonadoWs",targetNamespace="http://com.telefonica.bmws.ws",endpointInterface="com.telefonica.bmws.ws.DesbloqueaAbonadoWs")
public class DesbloqueaAbonadoWsImpl implements DesbloqueaAbonadoWs {
    
	protected static Logger logger = Logger.getLogger("DesbloqueaAbonadoWsImpl");
	@Resource
	WebServiceContext wsContext;
	
	
	@Override
	@WebMethod
	public String DesbloquearAbonado(String arg0 , String arg1) throws SQLException {
		
		MessageContext jaxwsContext =  wsContext.getMessageContext();
		HttpServletRequest request = (HttpServletRequest) jaxwsContext.get(SOAPMessageContext.SERVLET_REQUEST);
		String ipAddress = request.getRemoteAddr();
		logger.debug("Client IP consume --> " + ipAddress);
    	DesbloqueaAbonadoDAO dao = new DesbloqueaAbonadoDAO();
		DesbloqueaAbonadoResult result = new DesbloqueaAbonadoResult();
		DesbloqueaAbonadoParameter parameter = new DesbloqueaAbonadoParameter();
		parameter.CodigoEntidad = arg1;
		parameter.NumeroCelular = arg0;
		parameter.IpCliente = ipAddress;
		result = dao.DesbloquearAbonado(parameter);

		return result.Resultado + "|" + result.Mensaje;
	}
}
